Thursday 21 February 2019

FFMPEG


FFmpeg is a free software project that creates libraries and programs to handle multimedia data. Published under the GNU Lesser General Public License 2.1+ or GNU General Public License 2+.
it provides a complete solution for recording, converting and streaming audio and video files.

FFmpeg contains several components and supports various video and audio formats.
Some of the components include:

  • ffserver: a HTTP and RTSP multimedia streaming server for live broadcasts.
  • ffplay: is a simple media player based on SDL and on the FFmpeg libraries.
  • ffprobe: is a command line tool to show media information. 
  • Libavcodec: a library containing all the FFmpeg audio/video encoders and decoders.
  • Libavformat: a library containing demuxers and muxers for audio/video container formats.
  • Libavutil: a helper library containing routines common to different parts of FFmpeg.
  • Libpostproc: a library containing video postprocessing routines. 
  • Libswscale: a library containing video image scaling and colorspace/pixelformat conversion routines. 
  • libavfilter: this allows the video/audio to be modified or examined between the decoder and the encoder. 


Basic structure of an FFmpeg command

ffmpeg [input-options] -i [input-file] [output-options] [output-stream-URI]

An FFmpeg command is relatively simple. After installing FFmpeg, the program is invoked simply by typing ffmpeg at the command prompt.

Each instruction supplied to FFmpeg is a pair: a flag, which designates the type of action to be carried out; and the specifics of the action. Flags are always prepended with a hyphen.

A very basic FFmpeg command looks like this:
ffmpeg -i input.avi -c:v h264 output.mp4

For the example above the flag "-i" tells FFmpeg to use the input file input.avi, "-c:v" which is a shorthand for "-codec:video" tells FFmpeg to encode the input file using H.264 codecthe output is specified as output.mp4

FFmpeg can read from an arbitrary number of input "files" (which can be regular files, pipes, network streams, grabbing devices, etc.), specified by the "-i" flag, and write to an arbitrary number of output "files", which are specified by a plain output url. Anything found on the command line which cannot be interpreted as an option is considered to be an output url.

Each input or output url can contain any number of streams of different types (video/audio/subtitle/attachment/data). The allowed number and/or types of streams may be limited by the container format.

Transcoding process


The FFmpeg transcoding process for each output can be described as shown in Figure 1.

Figure 1 - Transcoding process in FFmpeg. (FFmpeg comand-line)

FFmpeg calls the libavformat library (containing demuxers) to read input files and get packets containing encoded data from them.

The encoded packets are then passed to the decoder, the decoder produces uncompressed frames which can be processed further by filtering. After filtering, the frames are passed to the encoder, which encodes them, and outputs encoded packets. 

Finally, the outputs encoded packets are passed to the muxer, which writes the encoded packets to the output file.


FFMPEG can be used to solve a variety of video and audio needs and the possibilities it offers are endless. The learning curve can be quite daunting, but the end result will definitely be worth the effort.


References:

Several FFMPEG tutorials are available through the official bug tracker and wiki: https://trac.ffmpeg.org/.

Another helpful resource is video engineer Fabio Sonnati’s excellent FFmpeg – The Swiss Army Knife of Internet Streaming (http://sonnati.wordpress.com/2011/07/11/ffmpeg-the-swiss-army-knife-of-internet-streaming-part-i/).

VideoLan also maintains excellent documentation on the x264 library:
http://www.videolan.org/developers/x264.html.

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search